package com.yanzhang.util;

import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author yanzhang
 */
public class PropertiesUtil {
    public static Properties getProperties (String fileName) {
        Properties properties = new Properties();
        try {
            InputStream is = PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName);
            properties.load(is);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return properties;
    }

    @Test
    public void test() {
        Properties properties = getProperties("db.properties");
        System.out.println(properties.getProperty("username"));
    }
}
